		
SuggestBoxForm = Ext.extend(Ext.Window, {
	// 构造函数
	constructor : function(_cfg) {
		Ext.applyIf(this, _cfg);
		// 必须先初始化组件
		this.initUIComponents();
		SuggestBoxForm.superclass.constructor.call(this, {
					id : 'SuggestBoxFormWin',
					layout : 'fit',
					items : this.formPanel,
					modal : true,
					height : 630,
					iconCls : 'menu-suggestbox',
					width : 735,
					maximizable : true,
					title : '意见详细信息',
					buttonAlign : 'center',
					buttons : this.buttons
				});
	},// end of the constructor
	// 初始化组件
	initUIComponents : function() {
		this.formPanel = new Ext.FormPanel({
			layout : 'vbox',
			bodyStyle : 'padding:10px 10px 10px 10px',
			border : false,
			url : __ctxPath + '/info/saveSuggestBox.do',
			defaults : {
				anchor : '95%,95%'
			},
			autoScroll : true,
			defaultType : 'textfield',
			items : [{
						name : 'suggestBox.boxId',
						xtype : 'hidden',
						value : this.boxId == null ? '' : this.boxId
					},{
						name : 'suggestBox.status',
						xtype : 'hidden',
						value : 0
					}, {
						xtype : 'radiogroup',
						fieldLabel : '签名方式',
						autoHeight : true,
						columns : 2,
						width : 520,
						items : [{
							boxLabel : '使用签名',
							name : 'SuggestBoxSign',
							inputValue : 1,
							checked : true,
							scope: this,
							handler : function(value) {
								if (value.getValue() != true) {
									this.formPanel.getCmpByName('PersonalInfo').hide();
									this.formPanel.getCmpByName('suggestBox.senderFullname').setValue('');
									this.formPanel.getCmpByName('suggestBox.senderId').setValue('');
								} else {
									this.formPanel.getCmpByName('PersonalInfo').show();
									if (curUserInfo != null) {
										this.formPanel.getCmpByName('suggestBox.senderFullname').setValue(curUserInfo.fullname);
										this.formPanel.getCmpByName('suggestBox.senderId').setValue(curUserInfo.userId);
									}
								}
							}
						}, {
							boxLabel : '匿名',
							name : 'SuggestBoxSign',
							inputValue : 0
						}]
					}, {
						xtype : 'fieldset',
						title : '个人信息',
						width: '100%',
						name: 'PersonalInfo',
						defaults : {
							xtype: 'textfield',
							labelAlign: 'right'
						},
						layout : {
							type: 'table',
							columns: 2,
							anchor: '98%'
						},
						items: [{
								fieldLabel: '发送人',
								name : 'suggestBox.senderFullname',
								value : curUserInfo !=null ? curUserInfo.fullname: null
							}, {
								fieldLabel: '联系电话',
								name : 'suggestBox.phone'
							}, {
								fieldLabel : 'Email',
								name : 'suggestBox.email',
								width: '90%',
								colspan: 2
							}]
					}, {
						fieldLabel : '意见标题',
						allowBlank : false,
						width: '100%',
						name : 'suggestBox.subject'
					}, {
						fieldLabel : '意见内容',
						name : 'suggestBox.content',
						allowBlank : false,
						width: '100%',
						height: 280,
						xtype : 'htmleditor'
					}, {
						fieldLabel : '发送人ID',
						name : 'suggestBox.senderId',
						xtype : 'hidden',
						value : curUserInfo !=null ? curUserInfo.userId : null
					}, {
						xtype : 'radiogroup',
						fieldLabel : '是否公开',
						autoHeight : true,
						columns : 2,
						width : 520,
						items : [{
							boxLabel : '公开',
							name : 'suggestBox.isOpen',
							inputValue : 0,
							checked : true,
							scope: this,
							handler : function(value) {
								if (value.getValue() == true) {
									this.formPanel.getCmpByName('SuggestBoxFormQueryPwd').hide();
								} else {
									this.formPanel.getCmpByName('SuggestBoxFormQueryPwd').show();
								}
							}
						}, {
							boxLabel : '不公开',
							name : 'suggestBox.isOpen',
							inputValue : 1
						}]
					}, {
						xtype : 'fieldset',
						title : '查询密码（选填）',
						width: '100%',
						name: 'SuggestBoxFormQueryPwd',
						hidden : true,
						defaults : {
							xtype: 'textfield',
							labelAlign: 'right'
						},
						layout : {
							type: 'table',
							columns: 2,
							anchor: '98%'
						},
						items : [{
									fieldLabel : '查询密码',
									name : 'suggestBox.queryPwd',
									inputType : 'password'
								}, {
									fieldLabel : '密码确认',
									name : 'SureQueryPwd',
									inputType : 'password',
									listeners : {
										change : function(field,newValue,oldValue){
											var queryPwd = this.formPanel.getCmpByName('suggestBox.queryPwd');
											if(queryPwd.getValue() != field.getValue()){
												Ext.Msg.alert('注意','两次输入的密码不一致,请重新填写.');
												queryPwd.setValue('');
												field.setValue('');
											}
										}
									}
								}]
					}

			]
		});
		// 加载表单对应的数据
		if (this.boxId != null && this.boxId != 'undefined') {
			this.formPanel.loadData({
						url : __ctxPath + '/info/getSuggestBox.do?boxId='
								+ this.boxId,
						preName : 'suggestBox',
						root : 'data'
					});
		}
		// 初始化功能按钮
		this.buttons = [{
					text : '提交',
					iconCls : 'btn-ok',
					scope : this,
					handler : this.draft
				},{
					text : '存草稿',
					iconCls : 'btn-save',
					scope : this,
					handler : this.save
				}, {
					text : '重置',
					iconCls : 'btn-reset',
					scope : this,
					handler : this.reset
				}, {
					text : '取消',
					iconCls : 'btn-cancel',
					scope : this,
					handler : this.cancel
				}];
	},// end of the initcomponents
	// 重置
	reset : function() {
		this.formPanel.getForm().reset();
	},
	// 取消
	cancel : function() {
		this.close();
	},
	//保存记录
	save : function() {
		var me = this;
		var content = this.formPanel.getCmpByName('suggestBox.content').getValue();
		if(content == '' || content == null || content == 'undefinded'){
			Ext.ux.Toast.msg('操作信息', '意见内容不能为空！');
			return ;
		}
		if (this.formPanel.getForm().isValid()) {
			this.formPanel.getForm().submit({
						method : 'POST',
						waitMsg : '正在提交数据...',
						success : function(fp, action) {
							Ext.ux.Toast.msg('操作信息', '成功保存信息！');
							var gridPanel = Ext.getCmp('SuggestBoxGrid');
							if (gridPanel != null) {
								gridPanel.getStore().reload();
							}
							me.close();
						},
						failure : function(fp, action) {
							Ext.MessageBox.show({
										title : '操作信息',
										msg : '信息保存出错，请联系管理员！',
										buttons : Ext.MessageBox.OK,
										icon : Ext.MessageBox.ERROR
									});
							me.close();
						}
					});
		}
	},
	draft : function(){
		this.formPanel.getCmpByName('suggestBox.status').setValue('1');
		this.save();
	}//end of draft
});